
#pragma once

#include "settings.h"
#include "vec.h"

namespace Blox
{
	class OBB;
	class Block
	{
	public:
		Block ( );
		virtual ~Block ( );

		void Init ( Block * parent, AABB const & rBox );
		void Init ( Block * parent, Bounds const & rBounds );
		void Clear ( );

		void Add ( OBB const & rblockage );
		void Split ( );
		bool IsSplit ( ) const { return pChildren[0]!=NULL; }

		Block * GetEncompassingBlock ( Bounds const & rObject ) const;

		bool Encompasses ( Bounds const & rObject ) const;

		void Report ( ) const;

		void DrawRecursive ( ) const; 
		void Draw ( ) const; 

	protected:
		void Report ( u32 uDepth ) const;

	private:
		// Parent
		Block * pParent;

		// Children
		Block * pChildren[Settings::CHILDREN_COUNT];
	
		// Physical Space.
		AABB vBox;
	};

}
